package com.project.controller.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.project.controller.BaseController;
import com.project.entity.activity.ActivityLog;
import com.project.entity.activity.ActivityUser;
import com.project.entity.user.Member;
import com.project.entity.user.User;
import com.project.service.activitylog.ActivityLogService;

/**
 * 用于获取：首页> 用户管理 
 * @author guo.junhui
 *
 */
@Controller
@RequestMapping("/user")
public class UserController extends BaseController<User>{
	
	@Autowired
	private ActivityLogService activityLogService;
	
	@Override
	protected Class<User> getClazz() {
		return User.class;
	}
	
	//用户管理-首页
	@RequestMapping("index")
	public String list(Model model,@ModelAttribute User user) {
		model.addAttribute("entity", user);
		model.addAttribute("list", service.query(user));
		return "/user/index";
	}

	//用户管理-查看用户
	@RequestMapping("checkUser")
	public String auditDetail(Model model,@ModelAttribute User user) {
		User retUser = service.queryEntity(user);
		model.addAttribute("retUser",retUser);
		
		ActivityLog activityLog = new ActivityLog();
		ActivityUser activityUser = new ActivityUser();
		activityUser.setUserId(retUser.getId());
		activityLog.setActivityUser(activityUser);
		List<ActivityLog> activityLogs = activityLogService.query(activityLog);
		model.addAttribute("activityLogs",activityLogs);
		return "/user/checkUser";
	}
}
